descriptives <- function(data, min_day = -30, max_day = 30) {

  # initial bindings
  win_cabinet <- election <- relative_date <- aes <- NULL
  `%>%` <- magrittr::`%>%`

  # Iceland plots -----------------------------------------------------------

  # plot data
  df_plot <- dplyr::filter(
    .data = data, election == "Iceland 2017 general election"
  ) %>%
    dplyr::mutate(win_cabinet = factor(
      x = win_cabinet, levels = c(0, 1),
      labels = c("Loser", "Winner")
    )) %>%
    dplyr::filter(relative_date >= min_day & relative_date <= max_day)

  # Iceland 2017 histogram
  icl_hist <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = relative_date)
  ) +
    ggplot2::geom_histogram(bins = diff(c(min_day, max_day)), color = "white") +
    ggplot2::scale_x_continuous(
      labels = seq(from = min_day, to = max_day, by = 5),
      breaks = seq(from = min_day, to = max_day, by = 5),
      limits = c(min_day, max_day)
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 100)) +
    ggplot2::geom_vline(xintercept = 0, lty = "dashed") +
    ggplot2::labs(
      x = "Interview date relative to government formation",
      y = "Number of respondents",
      title = "Iceland 2017",
      subtitle = paste0("Total number of respondents: ", nrow(df_plot))
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  # Iceland 2017 barplot
  icl_bar <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = win_cabinet)
  ) +
    ggplot2::geom_bar(
      fill = "white", color = "black", width = .9, alpha = 0.5
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 1250)) +
    ggplot2::labs(
      x = "Electoral status",
      y = "Number of respondents",
      title = "",
      subtitle = ""
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  # Norway plots ------------------------------------------------------------

  df_plot <- dplyr::filter(
    .data = data, election == "Norway 1997 general election"
  ) %>%
    dplyr::mutate(win_cabinet = factor(
      x = win_cabinet, levels = c(0, 1),
      labels = c("Loser", "Winner")
    )) %>%
    dplyr::filter(relative_date >= min_day & relative_date <= max_day)

  # Norway 1997 histogram
  nor_hist <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = relative_date)
  ) +
    ggplot2::geom_histogram(
      bins = diff(c(min_day, max_day)), color = "white"
    ) +
    ggplot2::scale_x_continuous(
      labels = seq(from = min_day, to = max_day, by = 5),
      breaks = seq(from = min_day, to = max_day, by = 5),
      limits = c(min_day, max_day)
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 100)) +
    ggplot2::geom_vline(xintercept = 0, lty = "dashed") +
    ggplot2::labs(
      x = "Interview date relative to government formation",
      y = "Number of respondents",
      title = "Norway 1997",
      subtitle = paste0("Total number of respondents: ", nrow(df_plot))
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  # Norway 1997 barplot
  nor_bar <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = win_cabinet)
  ) +
    ggplot2::geom_bar(
      fill = "white", color = "black", width = .9, alpha = 0.5
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 1250)) +
    ggplot2::labs(
      x = "Electoral status",
      y = "Number of respondents",
      title = "",
      subtitle = ""
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  # Netherlands plots -------------------------------------------------------

  df_plot <- dplyr::filter(
    .data = data, election == "Netherlands 2012 general election"
  ) %>%
    dplyr::mutate(win_cabinet = factor(
      x = win_cabinet, levels = c(0, 1),
      labels = c("Loser", "Winner")
    )) %>%
    dplyr::filter(relative_date >= min_day & relative_date <= max_day)

  # Netherlands 2010 histogram
  nld_hist <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = relative_date)
  ) +
    ggplot2::geom_histogram(
      bins = diff(c(min_day, max_day)), color = "white"
    ) +
    ggplot2::scale_x_continuous(
      labels = seq(from = min_day, to = max_day, by = 5),
      breaks = seq(from = min_day, to = max_day, by = 5),
      limits = c(min_day, max_day)
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 100)) +
    ggplot2::geom_vline(xintercept = 0, lty = "dashed") +
    ggplot2::labs(
      x = "Interview date relative to government formation",
      y = "Number of respondents",
      title = "Netherlands 2012",
      subtitle = paste0("Total number of respondents: ", nrow(df_plot))
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  # Netherlands barplot
  nld_bar <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = win_cabinet)
  ) +
    ggplot2::geom_bar(
      fill = "white", color = "black", width = .9, alpha = 0.5
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 1250)) +
    ggplot2::labs(
      x = "Electoral status",
      y = "Number of respondents",
      title = "",
      subtitle = ""
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 15),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 13),
      axis.title.x = ggplot2::element_text(vjust = -1, size = 12),
      axis.title.y = ggplot2::element_text(vjust = +2, size = 12),
      axis.text.y = ggplot2::element_text(size = 11, face = "plain"),
      axis.text.x = ggplot2::element_text(size = 11, face = "plain"),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white")
    )

  p <- ggpubr::ggarrange( # nolint
    widths = c(2, 1),
    icl_hist, icl_bar, nor_hist, nor_bar, nld_hist, nld_bar,
    ncol = 2, nrow = 3
  )

  ggplot2::ggsave(
    filename = "./figures/figure_S_A1.png",
    device = "png",
    width = 20,
    height = 25,
    units = "cm",
    dpi = 600
  )

  # plot with all elections pooled ------------------------------------------
  df_plot <- data %>%
    dplyr::mutate(win_cabinet = factor(
      x = win_cabinet, levels = c(0, 1),
      labels = c("Loser", "Winner")
    )) %>%
    dplyr::filter(relative_date >= min_day & relative_date <= max_day)


  # histogram
  all_hist <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = relative_date)
  ) +
    ggplot2::geom_histogram(
      bins = diff(c(min_day, max_day)), color = "white"
    ) +
    ggplot2::scale_x_continuous(
      labels = seq(from = min_day, to = max_day, by = 5),
      breaks = seq(from = min_day, to = max_day, by = 5),
      limits = c(min_day, max_day)
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 150)) +
    ggplot2::geom_vline(xintercept = 0, lty = "dashed") +
    ggplot2::labs(
      x = "Interview date relative to coalition government announcement",
      y = "Number of respondents"
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 12, color = "black"),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 11),
      axis.title.x = ggplot2::element_text(
        vjust = -1, size = 10, color = "black", family = "Courier New",
        margin = ggplot2::margin(t = 5)
      ),
      axis.title.y = ggplot2::element_text(
        vjust = +2, size = 10, color = "black", family = "Courier New",
        margin = ggplot2::margin(r = 10)
      ),
      axis.text.y = ggplot2::element_text(
        size = 9, face = "plain", color = "black"
      ),
      axis.line.x = ggplot2::element_line(color = "black", size = 0.4),
      axis.text.x = ggplot2::element_text(
        size = 9, face = "plain", color = "black"
      ),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white"),
      panel.grid.major.y = ggplot2::element_line(
        color = "black", size = 0.4, linetype = "dotted"
      ),
    )

  # barplot
  all_bar <- ggplot2::ggplot(
    data = df_plot, mapping = ggplot2::aes(x = win_cabinet)
  ) +
    ggplot2::geom_bar(
      fill = "white", color = "black", width = .9, alpha = 0.5
    ) +
    ggplot2::scale_y_continuous(limits = c(0, 2500)) +
    ggplot2::labs(
      x = "Electoral status",
      y = "Number of respondents",
      title = "",
      subtitle = ""
    ) +
    ggplot2::theme(
      plot.title = ggplot2::element_text(hjust = 0, size = 12),
      plot.subtitle = ggplot2::element_text(hjust = + 0, size = 11),
      axis.title.x = ggplot2::element_text(
        vjust = -1, size = 10, color = "black", family = "Courier New",
        margin = ggplot2::margin(t = 5)
      ),
      axis.title.y = ggplot2::element_text(
        vjust = +2, size = 10, color = "black", family = "Courier New",
        margin = ggplot2::margin(r = 5)
      ),
      axis.text.y = ggplot2::element_text(
        size = 9, face = "plain", color = "black"
      ),
      axis.text.x = ggplot2::element_text(
        size = 9, face = "plain", color = "black"
      ),
      axis.line.x = ggplot2::element_line(color = "black", size = 0.4),
      panel.background = ggplot2::element_rect(fill = "white"),
      plot.background = ggplot2::element_rect(fill = "white"),
      panel.grid.major.y = ggplot2::element_line(
        color = "black", size = 0.4, linetype = "dotted"
      ),
    )

  p <- ggpubr::ggarrange(
    widths = c(2, 1),
    all_hist, all_bar,
    ncol = 2, nrow = 1
  )

  ggplot2::ggsave(
    filename = "./figures/figure_3.png",
    device = "png",
    width = 21,
    height = 8.4,
    units = "cm",
    dpi = 600
  )

}
